package com.sqpoll.android;

import android.content.Intent;
import android.os.Bundle;

import com.actionbarsherlock.app.SherlockFragmentActivity;

/**
 * Activity for splash.
 * 
 * @author Honggyun Bae, Younggue Bae
 */
public class SplashActivity extends SherlockFragmentActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);

		// set time to splash out
		//final int welcomeScreenDisplay = 3000;
		final int welcomeScreenDisplay = 2000;

		// create a thread to show splash up to splash time
		Thread welcomeThread = new Thread() {
			int wait = 0;

			@Override
			public void run() {
				try {
					super.run();
					// use while to get the splash time. Use sleep() to increase the wait variable for every 100L.
					while (wait < welcomeScreenDisplay) {
						sleep(100);
						wait += 100;
					}
				} catch (Exception e) {
				} finally {

					// called after splash times up. Do some action after splash times up. Here we moved to another main activity
					// class
					startActivity(new Intent(SplashActivity.this, LoginActivity.class));
					finish();
				}
			}
		};
		welcomeThread.start();

	}
}